package mumethod;

import java.util.List;

import muobject.QuestionnaireSimpleSummary;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRField;

public class QuestionnaireSimpleReportDataSource implements JRDataSource{
	
	private List<QuestionnaireSimpleSummary> datas = null ;
	private int loop = -1 ; 
	
	public QuestionnaireSimpleReportDataSource(List<QuestionnaireSimpleSummary> data){
		this.datas = data;
	}
	
	public Object getFieldValue(JRField field) throws JRException {
		QuestionnaireSimpleSummary temp = (QuestionnaireSimpleSummary)this.datas.get(loop);
		Object rs = "" ;
		if("year".equals(field.getName())){  
			rs = temp.getYear();   
		}else if("grade".equals(field.getName())){
			rs = temp.getGrade();
		}else if("sclass".equals(field.getName())){
			rs = temp.getSclass();
		}else if("stno".equals(field.getName())){
			rs = temp.getStno();
		}else if("classno".equals(field.getName())){
			rs = temp.getClassno();
		}else if("ename".equals(field.getName())){
			rs = temp.getEname();
		}else if("cname".equals(field.getName())){
			rs = temp.getCname();
		}else if("sex".equals(field.getName())){
			rs = temp.getSex();
		}else if("age".equals(field.getName())){
			rs = temp.getAge();
		}else if("testdate".equals(field.getName())){
			rs = temp.getTestdate();
		}else if("d1score".equals(field.getName())){
			rs = temp.getD1score();
		}else if("d2score".equals(field.getName())){
			rs = temp.getD2score();
		}else if("d3score".equals(field.getName())){
			rs = temp.getD3score();
		}else if("d4score".equals(field.getName())){
			rs = temp.getD4score();
		}else if("d5score".equals(field.getName())){
			rs = temp.getD5score();
		}else if("d6score".equals(field.getName())){
			rs = temp.getD6score();
		}else if("d7score".equals(field.getName())){
			rs = temp.getD7score();
		}else if("d8score".equals(field.getName())){
			rs = temp.getD8score();
		}else if("d9score".equals(field.getName())){
			rs = temp.getD9score();
		}else if("d10score".equals(field.getName())){
			rs = temp.getD10score();
		}else if("d11score".equals(field.getName())){
			rs = temp.getD11score();
		}else if("d12score".equals(field.getName())){
			rs = temp.getD12score();
		}else if("d13score".equals(field.getName())){
			rs = temp.getD13score();
		}else if("d14score".equals(field.getName())){
			rs = temp.getD14score();
		}else if("d15score".equals(field.getName())){
			rs = temp.getD15score();
		}else if("dtotalscore".equals(field.getName())){
			rs = temp.getDtotalscore();
		}else if("f1score".equals(field.getName())){
			rs = temp.getF1score();
		}else if("f2score".equals(field.getName())){
			rs = temp.getF2score();
		}else if("f3score".equals(field.getName())){
			rs = temp.getF3score();
		}else if("f4score".equals(field.getName())){
			rs = temp.getF4score();
		}else if("f5score".equals(field.getName())){
			rs = temp.getF5score();
		}else if("f6score".equals(field.getName())){
			rs = temp.getF6score();
		}else if("f7score".equals(field.getName())){
			rs = temp.getF7score();
		}else if("f8score".equals(field.getName())){
			rs = temp.getF8score();
		}else if("f9score".equals(field.getName())){
			rs = temp.getF9score();
		}else if("f10score".equals(field.getName())){
			rs = temp.getF10score();
		}else if("ftotalscore".equals(field.getName())){
			rs = temp.getFtotalscore();
		}
		
		temp = null ;  
		return rs;
	}
	
	public boolean next() throws JRException {
		loop ++ ;
		if(loop >= datas.size()){
			return false;
		}
		else{   
			return true ;
		}
	}
	
	public void finalized(){
		datas = null ;  
	}
}
